package com.zkh.myutils.database.helper;

import com.zkh.myutils.database.enums.Symbol;

/**
 * 关系对象。条件类型：a=b, a in (), exists ()
 * @author zkh
 */
public class Relation {
	// 字段名称
	private String field;
	// 条件符号
	private Symbol sign;
	// 值
	private Object value;
	//占位符
	private boolean placeholder = true;
	
	/**
	 * 构造方法，条件取等于，且使用占位符
	 * @param field 条件字段
	 * @param value 条件值
	 */
	public Relation(String field, Object value) {
		this(field, value, true);
	}
	
	/**
	 * 构造方法，条件取等于
	 * @param field 条件字段
	 * @param value 条件值
	 * @param placeholder 是否占位
	 */
	public Relation(String field, Object value, boolean placeholder) {
		this(field, Symbol.EQ, value, placeholder);
	}

	/**
	 * 构造方法
	 * @param field 条件字段
	 * @param sign 条件符号
	 * @param value 条件值
	 */
	public Relation(String field, Symbol sign, Object value) {
		this(field, sign, value, true);
	}
	
	/**
	 * 构造方法
	 * @param field 条件字段
	 * @param value 条件值
	 * @param sign 条件符号
	 * @param placeholder 是否占位
	 */
	public Relation(String field, Symbol sign, Object value, boolean placeholder) {
		this.field = field;
		this.sign = sign;
		this.value = value;
		this.placeholder = placeholder;
	}
	
	public String getField() {
		return field;
	}

	public void setField(String field) {
		this.field = field;
	}
	public Symbol getSign() {
		return sign;
	}
	public void setSign(Symbol sign) {
		this.sign = sign;
	}
	public Object getValue() {
		return value;
	}
	public void setValue(Object value) {
		this.value = value;
	}
	public boolean isPlaceholder() {
		return placeholder;
	}
	public void setPlaceholder(boolean placeholder) {
		this.placeholder = placeholder;
	}
}
